<?php if ($addressbook) { ?>
    <form class="form-horizontal" action="<?= current_url() ?>" method="post" id="form-validate" >
        <div id="validation" class="row-fluid">
            <div class="span12">
                <div class="box corner-all">
                    <div class="box-header grd-white color-silver-dark corner-top">
                        <div class="header-control">
                            <a data-box="collapse"><i class="icofont-caret-up"></i></a>

                        </div>
                        <span><?= lang('label_menu_link_addressbooks'); ?></span>
                    </div>
                    <div class="box-body">

                        <fieldset>
                            <legend><?= lang('label_edit') ?> <?= $addressbook->name ?></legend>

                            <div class="control-group">
                                <label class="control-label" for="name"><?= lang('label_name') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="name" placeholder="<?= lang('label_name') ?>" id="name"  value="<?= (form_val('name')) ? form_val('name') : $addressbook->name ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="mobile"><?= lang('label_mobile') ?></label>
                                <div class="controls">
                                    <input type="text" class="grd-white" name="mobile" placeholder="<?= lang('label_mobile') ?>" id="mobile"  value="<?= (form_val('mobile')) ? form_val('mobile') : $addressbook->mobile ?>" />
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="city"><?= lang('label_city') ?></label>
                                <div class="controls">
                                    <select name="city" id="city" data-form="select2">
                                        <?php foreach ($cities as $ct) { ?>
                                            <option value="<?= $ct->id ?>" <?php
                                            if (form_val('city') == $ct->id) {
                                                echo 'selected';
                                            } else {
                                                if ($addressbook->cities_id == $ct->id)
                                                    echo 'selected';
                                            }
                                            ?>><?= $ct->title ?></option>
                                                <?php } ?>
                                    </select>

                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="address"><?= lang('label_address') ?></label>
                                <div class="controls">
                                    <textarea name="address" id="address" style="height: 138px;" placeholder="<?= lang('label_address') ?>"  ><?= (form_val('address')) ? form_val('address') : $addressbook->address ?></textarea>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="default"></label>
                                <div class="controls">
                                    <label class="checkbox">
                                        <input type="checkbox" data-form="uniform" name="default" id="inlineCheckbox1" placeholder="<?= lang('label_default') ?>" <?php
                                        if (isset($addressbook)) {
                                            if ($addressbook->default == 'YES')
                                                echo 'checked';
                                        }
                                        
                                        ?> type="checkbox" ><?= lang('label_default') ?>
                                    </label>

                                </div>
                            </div>
                           
                            <div class="form-actions">
                                <button type="submit" class="btn"><?= (isset($addressbook)) ? lang('label_edit') : lang('label_add'); ?></button>
                                <button type="button" class="btn">Cancel</button>
                            </div>
                        </fieldset>


                    </div>
                </div>
            </div>
        </div>

    </form>
<?php }else show_404(); ?>